{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 移除所有.开头的文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import shutil\n",
    "\n",
    "def move_hidden_files(source_dir, target_dir):\n",
    "    # 检查目标目录是否存在，如果不存在则创建\n",
    "    if not os.path.exists(target_dir):\n",
    "        os.makedirs(target_dir)\n",
    "    \n",
    "    # 遍历源目录\n",
    "    for root, dirs, files in os.walk(source_dir):\n",
    "        for file in files:\n",
    "            # 检查文件是否以点开头\n",
    "            if file.startswith('.'):\n",
    "                # 构建完整的文件路径\n",
    "                file_path = os.path.join(root, file)\n",
    "                # 构建目标文件路径\n",
    "                dest_path = os.path.join(target_dir, file)\n",
    "                # 移动文件\n",
    "                shutil.move(file_path, dest_path)\n",
    "                print(f'Moved: {file_path} -> {dest_path}')\n",
    "\n",
    "# 源目录和目标目录\n",
    "source_directory = ''  # 替换为你的源目录路径\n",
    "target_directory = ''  # 替换为你的目标目录路径\n",
    "\n",
    "# 调用函数\n",
    "move_hidden_files(source_directory, target_directory)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "torch",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
